<!DOCTYPE html>
<html>
<head>
    <title>修改评论 - {:config('web.WEB_AUT')}</title>
    {include file="index/header"}
    <link rel="stylesheet" href="/public/wangEditor/css/wangEditor.min.css">
    <script type="text/javascript" src="/public/wangEditor/js/wangEditor.min.js"></script>
    <style type="text/css">
        .wangEditor-menu-container .menu-item a {
            padding: 12px 0;
        }

        .wangEditor-menu-container .menu-item {
            height: 37px;
            width: 37px;
        }

        .wangEditor-menu-container .menu-group {
            padding: 0;
        }

        .wangEditor-container {
            border: 1px solid #e6e6e6;
        }
    </style>
    <div class="tpt-wp cl">
        <div class="tpt-forum cl">
            <blockquote class="layui-elem-quote">修改评论</blockquote>
            <form class="layui-form layui-form-pane" method="post" style="padding: 10px 0 0 0;">
                <div class="layui-form-item">
                    <label for="L_title" class="layui-form-label">所属帖子</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$tptc.title}" autocomplete="off" class="layui-input" disabled>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <div class="layui-input-block">
                        <textarea id="textarea" name="content" required lay-verify="content"
                                  style="height:400px;width: 100%;">{$tptc.content}</textarea>
                    </div>
                    <label for="L_content" class="layui-form-label" style="top: -2px;">内容</label>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn" lay-submit="" lay-filter="comment_edit">立即发布</button>
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        var editor = new wangEditor('textarea');
        editor.config.uploadImgUrl = '{:url("index/upload/doUploadPic")}';
        editor.config.uploadImgFileName = 'FileName';
        var W = document.documentElement.clientWidth || document.body.clientWidth;
        if (W < 1008) {
            editor.config.menus = [
                'bold',
                'underline',
                'italic',
                'forecolor',
                'link',
                'fullscreen',
            ];
        } else {
            editor.config.menus = [
                'bold',
                'underline',
                'italic',
                'strikethrough',
                'forecolor',
                'link',
                'unlink',
                'emotion',
                'img',
                'insertcode',
                'fullscreen',
            ];
        }
        editor.config.pasteText = true;
        editor.create();
    </script>
    <script type="text/javascript">
        layui.use('form', function () {
            var form = layui.form,
                jq = layui.jquery;

            form.verify({
                content: function (value) {
                    if (value.replace(/<[^<>]+?>|[ ]|[&nbsp;]/g, '') == '') {
                        return '内容不得为空';
                    }
                }
            });
            form.on('submit(comment_edit)', function (data) {
                loading = layer.load(2, {
                    shade: [0.2, '#000']
                });
                var param = data.field;
                jq.post('{:url("index/comment/edit",array("id"=>$tptc.id))}', param, function (data) {
                    if (data.code == 200) {
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                            location.href = '{:url("index/user/comment")}';
                        });
                    } else {
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                    }
                });
                return false;
            });
        })
    </script>
    {include file="index/footer"}
    </body>
</html>